package cn.iune.controllers;

import java.util.Arrays;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.iune.freemarker.FreemarkerUtil;

@Controller
public class FreemarkerController {

	
    @RequestMapping(value = "/")
    public String index(Model model){
    	Map map = new LinkedHashMap<>();
    	for (int i = 0; i < 5; i++) {
    		map.put("key" + i, "value" + i);
    	}
    	model.addAttribute("list", Arrays.asList("string1", "string2", "string3", "string4", "string5", "string6"));
    	model.addAttribute("map", map);
    	model.addAttribute("name", "   htTps://wWw.zHyD.mE   ");
    	model.addAttribute("htmlText", "<span style=\"color: red;font-size: 16px;\">html内容</span>");
    	model.addAttribute("num", 123.012);
    	model.addAttribute("null", null);
    	model.addAttribute("dateObj", new Date());
    	model.addAttribute("bol", true);
//    ————————————————
//    版权声明：本文为CSDN博主「七彩狼」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//    原文链接：https://blog.csdn.net/u011197448/java/article/details/83901306
        System.out.println("/index");
        return "index";
    }
    
    
    @RequestMapping("/createHtml")
    @ResponseBody
    public String createHtml(Model model){
    	Map map = new LinkedHashMap<>();
    	for (int i = 0; i < 5; i++) {
    		map.put("key" + i, "value" + i);
    	}
    	model.addAttribute("list", Arrays.asList("string1", "string2", "string3", "string4", "string5", "string6"));
    	model.addAttribute("map", map);
    	model.addAttribute("name", "   htTps://wWw.zHyD.mE   ");
    	model.addAttribute("htmlText", "<span style=\"color: red;font-size: 16px;\">html内容</span>");
    	model.addAttribute("num", 123.012);
    	model.addAttribute("null", null);
    	model.addAttribute("dateObj", new Date());
    	model.addAttribute("bol", true);
    	return FreemarkerUtil.parseTpl("index", model.asMap());
    }
//    ————————————————
//    版权声明：本文为CSDN博主「七彩狼」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//    原文链接：https://blog.csdn.net/u011197448/java/article/details/83901306
    	
    	
    	

}
